//package com.sztz.handle;
//
//import cn.hutool.json.JSONObject;
//import cn.hutool.json.JSONUtil;
//import com.sztz.result.BaseResult;
//import com.sztz.utils.CommUtils;
//import com.sztz.utils.JwtTokenUtils;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.context.SecurityContextHolder;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * 自定义登录认证成功处理器
// * @author yzy
// * @date 2023/3/15 14:50
// */
//@Component
//@Slf4j
//public class MyAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
//    @Override
//    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
//        UserDetails userDetails = (UserDetails) authentication.getPrincipal();
//        SecurityContextHolder.getContext().setAuthentication(authentication);
//        log.info("用户登录认证授权成功 MyAuthenticationSuccessHandler: {}", userDetails.getUsername());
//        String token = JwtTokenUtils.generateToken(userDetails.getUsername());
//        JSONObject obj = JSONUtil.createObj();
//        obj.putOpt("accessToken",token);
//        CommUtils.responseJsonMessage(response,JSONUtil.toJsonStr(BaseResult.success(obj)));
//    }
//}
